#ifndef COLLECTIVE_MATH_H
#define COLLECTIVE_MATH_H

#include "Vector.h"
#include "Matrix.h"

#include "VectorVector.h"
#include "MatrixMatrix.h"
#include "VectorMatrix.h"

#include "VectorCode.h"
#include "MatrixCode.h"

#include "VectorScalarCode.h"
#include "VectorVectorCode.h"
#include "MatrixScalarCode.h"
#include "MatrixMatrixCode.h"
#include "VectorMatrixCode.h"

#include "MathShortHand.h"

const float  PI_f = 3.141592654f;
const double PI_d = 3.141592655359;

template< typename T >
void WrapValue( T& value, T min, T max ) {
  T offset = value - min;
  offset = (offset / (max-min));
  offset = offset - (int)offset;
  value = min + offset*(max-min);
}

inline void WrapValue( int& value, int min, int max ) {
  int offset = value - min;
  offset %= (max-min);
  value = min + offset;
}

template< typename T >
void Clamp( T& value, T min, T max ) {
  if( value < min )
    value = min;
  else if( value > max )
    value = max;
}

template< typename T >
T ABS( const T& A ) {
  if( A >= 0 ) {
    return A;
  }
  return -A;
}

#endif
